package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.bean.TrainnInBean;
import neusoft.yuejian_11.R;
import neusoft.yuejian_11.viewHolder.ClubitemViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by neusoft on 2017/10/23.
 */

public class InformationListAdapter extends BaseListAdapter {
    public InformationListAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_club_list, parent, false);
        ClubitemViewHolder viewHolder = new ClubitemViewHolder(itemView);
        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        TrainnInBean train = (TrainnInBean) data.get(position);
        ClubitemViewHolder viewHolder = (ClubitemViewHolder) holder;

        final int trainId = train.getT_id();
        String trainTime = train.getT_time();
        String trainAddress = train.getT_address();
        final String trainName = train.getT_name();

        viewHolder.clubTimeView.setText(trainTime);
        viewHolder.clubPhoneView.setText(trainAddress);
        viewHolder.clubNameView.setText(trainName);

        //String realPath = “file://”+new File(event.photo).getPath();
        final String trainPic = BASE_URI+"trainpicture/"+train.getT_picture();
        //String Url = "http://10.0.2.2/yuejian14/Public/Admin/clubphoto/87.jpg";
        Picasso.with(context)
                .load(trainPic)
                .placeholder(R.drawable.ic_club)
                .error(R.drawable.ic_noclub)
                .into(viewHolder.imageView);

    }
}
